package com.example.demo2.service;

import com.example.demo2.bean.MessagesBean;
import com.example.demo2.dao.MessagesBeanDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessagesBeanService {

    @Autowired
    MessagesBeanDao dao;

    public List<MessagesBean> list(){
        List<MessagesBean> all = dao.findAll();
        return all;
    }

    public MessagesBean findone(MessagesBean messagesBean) {
        MessagesBean MessagesBean1 = dao.findOne(Example.of(messagesBean)).orElse(null);
        return MessagesBean1;
    }

//    public void deleteById(Integer id) {
//        dao.deleteById(id);
//    }
//
//    public MessagesBean update(MessagesBean messagesBean) {
//        com.example.demo2.bean.MessagesBean save = dao.save(messagesBean);
//        return save;
//    }
//
    public MessagesBean addone(MessagesBean messagesBean) {
        com.example.demo2.bean.MessagesBean save = dao.save(messagesBean);
        return save;
    }
}
